﻿@using Think9.Models;
@{ ViewBag.Title = "Index";
    Layout = "~/Areas/Shared/_LayuiList.cshtml"; }

<script src="~/lib/layui/layui.js" charset="utf-8"></script>
<input style="display:none" id="rpId" value="@ViewBag.RpId">

<blockquote class="layui-elem-quote layui-text">
    条件参数需要被赋值，赋值的方式包括：1.在统计指标出现的位置,即统计表单元格中赋值; 2.定义动态行为参数赋值; 3.定义查询参数为参数赋值;  优先级为1>2>3<br>
    本页面只能综合查看参数赋值情况并对其删除，如需对参数赋值管理，请进入相应页面
</blockquote>
<span style="position: absolute;top: 20px; right: 20px;" id="blockquote_close">
    <i class="fa fa-close" style="color: #FFAB00;" id="tipsWhereStr"></i>
</span>
<table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
<script>
    layui.use(["table", "form", "exLayer", "exUtils"], function () {
        let table = layui.table;
        let form = layui.form;
        let exLayer = layui.exLayer;
        let exUtils = layui.exUtils;
        let $ = layui.$;

        form.render(); //

        $("#blockquote_close").click(function () {
            $(".layui-elem-quote").attr("style", "display:none");
            $("#blockquote_close").attr("style", "display:none");
        });

        let ThisTable = table.render({
            elem: "#tableId",
            url: "/SysStats/Report/GetReportParmAssign?rpId=" + $("#rpId").val(),
            method: "post",
            page: false,
            defaultToolbar: [{ title: '刷新', layEvent: 'refresh', icon: 'layui-bg-gray layui-icon-refresh' }],
            toolbar: "#toolbarTpl",
            cols: [[
                { type: "checkbox" },
                { field: "Type", title: "方式", width: 150, sort: true },
                { field: "Postion", title: "位置", width: 200, sort: true },
                { field: "ParmName", title: "参数", width: 300, sort: true },
                { field: "ParmValue", title: "参数值" },
                { field: "Description", title: "备注", width: 200, templet: "#Description" }

            ]],
            done: function (res, curr, count) {
                console.log(res, curr, count);
            }
        });

        table.on("toolbar(tableFilter)", function (obj) {
            switch (obj.event) {
                case "refresh":
                    refresh();
                    break;
                case "batchDel":
                    batchDel();
                    break;
            }
        });

        table.on("tool(tableFilter)", function (obj) {
            let data = obj.data;
            switch (obj.event) {
                case "del":
                    del(data.ListId);
                    break;
            }
        });

        function refresh() {
            ThisTable.reload({
                where: { rpId: $("#rpId").val() }
            });
        }

        function batchDel() {
            var idsStr = "";
            var checkStatus = table.checkStatus("tableId");
            var rows = checkStatus.data.length;
            if (rows > 0) {
                for (var i = 0; i < checkStatus.data.length; i++) {
                    idsStr += checkStatus.data[i].StrID + ",";
                }
                exLayer.confirm("确定要删除吗？", function (index) {
                    layer.close(index);
                    if (idsStr) {
                        exUtils.ajax("/SysStats/Report/BatchDelReportParm", "post", { idsStr: idsStr }, true).done(function (response) {
                            exUtils.tableSuccessMsg(response.message);
                            ThisTable.reload({
                                where: { rpId: $("#rpId").val() }
                            });
                        }).fail(function (error) {
                            console.log(error);
                        });
                    }
                });
            }
            else {
                layer.msg("未选择有效数据");
            }
        }
    });</script>
<!-- 头工具栏模板 -->
<script type="text/html" id="toolbarTpl">
    <button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="batchDel" id="batchDel"><i class="fa fa-trash-o"></i></button>
</script>
<!-- 行工具栏模板 -->
<script type="text/html" id="operationTpl">
    <a href="javascript:;" class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del" id="del"><i class="fa fa-remove"></i></a>
</script>
<script type='text/html' id='Description'>
    <span style="color: #FE7300;">{{d.Description}}</span>
</script>